You specify attributes of joins by including kCurveJoinAttributesAtom and kCurveMiterLimitAtom atoms in a vector data stream. The kCurveJoinAttributesAtom atom specifies the type of join, and the kCurveMiterLimitAtom specifies the miter limit for joins. For more information about join types and miter limits, see "Joins" .
As with other atoms that specify path attributes, an attribute value specified by a kCurveJoinAttributesAtom or kCurveMiterLimitAtom atom is used for subsequent paths in the vector data stream until another atom of the same type appears in the stream or the end of the stream is reached.
Listing 5 shows how to specify a sharp join for an angle.
Listing 5 Adding a sharp join to an angle
ComponentInstance vectorCodec;
Handle streamH;
Handle pathH;
gxPoint points[3];
Boolean isOnCurve[3];
int i;
long value;
/* open the vector codec component */
OpenADefaultComponent (decompressorComponentType,
kVectorCodecType, &vectorCodec);
/* create a new vector data stream */
CurveCreateVectorStream (vectorCodec, streamH);
value=gxOpenFrameFill;
value=ff(15);
value=gxSharpJoin;
value=gxPositiveInfinity;
/* add an atom to the vector data stream that specifies that
subsequent paths are to be drawn with open frame fill */
CurveAddAtomToVectorStream (ci, kCurveFillTypeAtom, sizeof(long),
&value, streamH);
/* add an atom to the vector data stream that specifies that
subsequent paths are to be drawn with a pen width of 15 */
CurveAddAtomToVectorStream (ci, kCurvePenThicknessAtom, sizeof(Fixed),
&value, streamH);
/* add an atom to the vector data stream that specifies that
subsequent paths are to be drawn with sharp angle joins*/
CurveAddAtomToVectorStream (ci, kCurveJoinAttributesAtom,
sizeof(gxJoinAttribute),
&value, streamH);
/* add an atom to the vector data stream that specifies that
subsequent paths are to have no miter limit for joins */
CurveAddAtomToVectorStream (ci, kCurveMiterLimitAtom, sizeof(Fixed),
&value, streamH);
/* specify the points for the path and whether each one is
on the path */
points[0].x = ff(20);
points[0].y = ff(20);
isOnCurve[0] = TRUE;
points[1].x = ff(250);
points[1].y = ff(60);
isOnCurve[1] = FALSE;
points[2].x = ff(20);
points[2].y = ff(100);
isOnCurve[2] = TRUE;
/* create the path and add the points to it */
CurveNewPath (vectorCodec, &pathH);
for (i = 0; i <= 2; i++)
CurveInsertPointIntoPath (vectorCodec, &points[i], pathH,
1, i, isOnCurve[i]);
/* add the path to the vector data stream */
CurveAddPathAtomToVectorStream (vectorCodec, pathH, streamH);
/* mark the end of the vector data stream by adding a
kCurveEndAtom atom to the stream */
CurveAddZeroAtomToVectorStream (vectorCodec, streamH);
/* use the vector codec here to decompress and display the vector data */
/* dispose of stream and path handles when done */
DisposeHandle (streamH);
DisposeHandle (pathH);
Notice that miter limit is set to the constant value gxPositiveInfinity , which indicates the join should be as sharp as necessary.
Figure 65 shows what is drawn for this vector data stream.
Figure 65 An angle with a sharp join
If you limit the miter of the sharp join, for example, with the code
/* add an atom to the vector data stream that specifies that
subsequent paths are to have no miter limit for joins */
CurveAddAtomToVectorStream (ci, kCurveMiterLimitAtom, sizeof(Fixed),
&value, streamH);
the vector codec limits the distance between the actual corner of the contour as specified in the shape's geometry and the tip of the corner as actually drawn. Since the miter is scaled by the pen width, and the pen width in this example is 15, the vector codec truncates the sharp join 15 points away from the actual corner of the geometry, as shown in Figure 66 .
Figure 66 An angle with a truncated sharp join
| Previous | Chapter Contents | Chapter Top | Next |